package com.flying.oop.classmember.method;

import java.util.Arrays;

/**
 * @ClassName: ParamDemo
 * @createDate: 2023/6/22 8:33
 * @author: liu
 * @description:方法传参的注意事项
 */
public class ParamDemo {
    public static void main(String[] args) {
        int x = 5;   // 基本数据类型传参，只传数据，不参与业务逻辑
        demo(x);
        System.out.println(x);   //   5

        int[] arr1=new int[]{1,77,43,12,65,69,74,4};
        bubbleSort(arr1);
        System.out.println(Arrays.toString(arr1));

    }

    public static void demo(int a) {
        a = 10;
    }

    // 引用数据类型传参时，传的是内存地址
    public static void bubbleSort(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length - 1; j++) {
                if (nums[j] > nums[j + 1]) {
                    int temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = temp;
                }
            }
        }
    }

}
